package com.zjw;

import com.zjw.entity.Admin;
import com.zjw.service.TradeLogService;
import com.zjw.service.impl.TradeLogServiceImpl;
import com.zjw.utils.Constants;
import com.zjw.vo.TradeLogDetail;

import java.util.List;
import java.util.Scanner;

public class AdminMenu {
    private Admin admin;

    public AdminMenu(Admin admin) {
        this.admin = admin;
    }

    private Scanner input = new Scanner(System.in);

    public void showAdminMenu() {
        do {
            System.out.println("1.查询交易记录");
            System.out.println("2.生成交易报告");
            System.out.println("3.查看好物列表");
            System.out.println("4.下架不合格商品");
            System.out.println("4.封禁违规账号");
            System.out.println("0.退出登录");
            System.out.println("请输入您要执行的操作：");
            int choice = input.nextInt();
            switch (choice) {
                case 1:
                    queryTransactions();
                    break;
                case 2:
                    break;
                case 3:
                    CommonOperate.getGoodsList(Constants.LOGIN_TYPE_ADMIN , 0);
                    break;
                case 4:
                    break;
                case 0:
                    return;
                default:
                    System.out.println("输入有误，请重新输入");
            }
            System.out.println();
        } while (true);
    }

    /**
     * 查询交易记录
     */
    private void queryTransactions() {
        TradeLogService tradeLogService = new TradeLogServiceImpl();
        List<TradeLogDetail> list = tradeLogService.findAll();
        System.out.println("交易编号\t\t买家\t\t商品名称\t\t卖家\t\t收货地址");
        for (TradeLogDetail tradeLogDetail : list) {
            System.out.println(tradeLogDetail.getLodId()+ "\t\t" + tradeLogDetail.getBuyerName() + "\t\t" + tradeLogDetail.getGoodsName() + "\t\t" + tradeLogDetail.getSellerName() + "\t\t" + tradeLogDetail.getAddress());
        }
    }
}
